{% extends "admin/base.html" %}
{% load i18n %}

{% block content %}
<form action="{{ form.action }}" method="post">{% csrf_token %}
    <input onClick="history.back()" type="button" value="{% trans 'Back' %}" />
    <input type="submit" name="2select" value="{% trans 'Change selection' %}" />
    {% include "bots/paginator.html" %}

    <table id="botstable">
        {% for hidden in form.hidden_fields %}
            {{ hidden }}
        {% endfor %}
        <thead>
            <tr>
                <th></th>
                <th><button class="botsheader" type="submit" name="order" value="status" />{% trans 'Phase' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="botskey" />{% trans 'Document number' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="reference" />{% trans 'Reference' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="ts" />{% trans 'Date' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="confirmtext" />{% trans 'Confirm' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="idroute" />{% trans 'Route' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="fromchannel" />{% trans 'Channel' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="frompartner" />{% trans 'FromPartner' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="topartner" />{% trans 'ToPartner' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="editype" />{% trans 'Editype' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="messagetype" />{% trans 'Messagetype' %}</button></th>
            </tr>
        </thead>
        <tbody>
        {% for row in queryset.object_list %}
            <tr class="{% cycle 'row1' 'row2' %}">
                <td>
                    <div class="dropdown"><img class="action" src="/media/images/star.png" />
                        <ul>
                            <li><button class="botsheader" onclick="window.open('/filer/?action=this&amp;idta={{row.idta}}'); return false;">{% trans 'View this file' %}</button></li>
                            {% if row.incoming %} 
                                <li><button class="botsheader" onclick="document.location.href='/detail/?inidta={{row.incoming}}'; return false;">{% trans 'View detail' %}</button></li>
                                <li><button class="botsheader" onclick="window.open('/filer/?action=this&amp;idta={{row.incoming}}'); return false;">{% trans 'View incoming file' %}</button></li>
                                <li><button class="botsheader" type="submit" name="retransmit" value="{{row.incoming}}" />{% trans 'Retransmit' %}</button></li>
                            {% else %}
                                <li><button class="botsheader" onclick="window.open('/filer/?action=this&amp;idta={{row.outgoing}}'); return false;">{% trans 'View outgoing file' %}</button></li>
                            {% endif %}
                        </ul>
                    </div>
                </td>
                <td>{{row.get_status_display}}</td>
                <td><a href="/filer/?action=this&amp;idta={{row.idta}}" class="botslink" target="_blank">{{row.botskey}}</a></td>
                <td>{{row.reference}}</td>
                <td class="nowrap">{{row.ts|date:"Y-m-d H:i:s"}}</td>
                <td  style="white-space: pre;">{{row.confirmtext}}</td>
                <td>{{row.idroute}}</td>
                <td>{{row.channel}}</td>
                <td>{{row.frompartner}}</td>
                <td>{{row.topartner}}</td>
                <td>{{row.editype}}</td>
                <td>{{row.messagetype}}</td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
</form>
{% endblock %}

